package com.feicheng.persistence.controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.persistence.entity.ARoom;
import com.feicheng.persistence.entity.Client;
import com.feicheng.persistence.mapper.AStoreMapper;
import com.feicheng.persistence.service.impl.ARoomServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 房间表 前端控制器
 * </p>
 *
 * @author Ms.wu
 * @since 2025-02-20
 */
@RestController
@RequestMapping("/admin/room")
public class ARoomController {
    @Autowired
    ARoomServiceImpl aRoomService;

    @Autowired
    AStoreMapper aStoreMapper;

    //分页查询
    @GetMapping("/page")
    public ResultInfo getClientsPage(
            @RequestParam(defaultValue = "1")Integer current,
            @RequestParam(defaultValue = "10")Integer size,
            String roomname,String test){
        JSONObject param = new JSONObject();
        param.put("roomname",roomname);
        System.out.println("我的测试："+test);
        return aRoomService.getRoomByPage(current,size,param);

    }

    //新增时获取门店名称
    @GetMapping("/StoreName")
    public ResultInfo getStoreName(){
        return ResultInfo.success(aStoreMapper.selectList(null));
    }

    //新增房间
    @PostMapping("/info")
    public ResultInfo newRoom(String room){
        ARoom aRoom = JSONObject.parseObject(room,ARoom.class);
        JSONObject param = new JSONObject();
        param.put("room",aRoom);
        return aRoomService.newRoom(param);
    }

    //删除房间号
    @DeleteMapping("/info")
    public ResultInfo deleteRoom(String roomid){
        return aRoomService.deleteRoom(roomid);
    }
}
